package Aop.Utility;

import Aop.Element.Vector;

public class AngleUtility
{
	public AngleUtility()
	{
		throw new Error("Static Class");
	}
	
	static public double RevisionDegree(double origianlDegree)
	{
		return origianlDegree % 360;
	}
	
	static public double GetGradientByDegree(Vector v1, Vector v2)
	{
		double gradientRadians = GetGradientByRadians(v1, v2);
		
		return RevisionDegree(Math.toDegrees(gradientRadians));
	}
	
	static public double GetGradientByRadians(Vector v1, Vector v2)
	{
		Vector gradientVector = Vector.Zero();
		gradientVector = v2.Subtract(v1);
		
		return Math.atan2(gradientVector.GetY(), gradientVector.GetX());
	}
	
	static public Vector pixelDegreeDistanceResultPixel(Vector position, double degree, double distance)
	{
		return pixelRadiansDistanceResultPixel(position, Math.toRadians(degree), distance);
	}

	static public Vector pixelRadiansDistanceResultPixel(Vector position, double radians, double distance)
	{
		Vector result = Vector.Zero();
		
		result.SetX(position.GetX() + (Math.cos(radians) * distance));
		result.SetY(position.GetY() + (Math.sin(radians) * distance));

		return result;
	}
}
